package com.sgb.goods.widget.pop;

import android.content.Context;

import com.sgb.goods.R;
import com.swgk.core.dialog.BasePopWindow;
import com.swgk.core.dialog.PopViewHolder;

/**
 * 描述：发布询价-商品新增方式的弹窗
 *
 * @author qiangHeNoo
 * <p>
 * 时间：2021.12.13
 */
public class AddGoodsPopWindow extends BasePopWindow<Object> {

    private OnClickCallBack onClickCallBack;

    public AddGoodsPopWindow(Context context) {
        super(context, DIR_DOWN_UP);
    }

    @Override
    protected int popLayout() {
        return R.layout.goods_add_goods_pop_window;
    }

    @Override
    protected void initView(PopViewHolder holder) {
        holder.getPop().findViewById(R.id.tv_goods_copy).setOnClickListener(v -> {
            if (onClickCallBack != null) {
                onClickCallBack.copy();
            }
            dissMiss();
        });
        holder.getPop().findViewById(R.id.tv_goods_add).setOnClickListener(v -> {
            if (onClickCallBack != null) {
                onClickCallBack.add();
            }
            dissMiss();
        });

        holder.getPop().findViewById(R.id.tv_goods_cancel).setOnClickListener(v -> {
            if (onClickCallBack != null) {
                onClickCallBack.cancel();
            }
            dissMiss();
        });
    }

    public void setOnClickCallBack(OnClickCallBack onClickCallBack) {
        this.onClickCallBack = onClickCallBack;
    }

    public interface OnClickCallBack {
        /***
         * 复制当前商品
         */
        void copy();

        /***
         * 新增一条商品
         */
        void add();

        /***
         * 取消
         */
        void cancel();
    }

    @Override
    public void dismiss() {
        super.dismiss();
        clearAlpha();
    }
}
